package com.su02.multi.examples.mlp;

import com.su02.multi.chainrule.Function;

import java.util.Map;

public class ReLU4MLP extends Function {
    private final Function f;

    public ReLU4MLP(Function f) {
        this.f = f;
        this.setBs(f.getBs());
    }

    @Override
    public Function doBackward(int id) {
        return new ReLU4MLP(f.backward(id));
    }

    @Override
    public double forward(Map<Integer, Double> vector) {
        return Math.max(0, f.forward(vector));
    }
}